home *** CD-ROM | disk | FTP | other *** search
/ PC-X 1997 October / pcx14_9710.iso / swag / files.swg / 0099_Convert ICO file to INC file.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-11-29  |  2.3 KB  |  97 lines

  1. {
  2.  
  3.    The purpose  of this  program is to  convert an ICON  into an  INC file.
  4.  
  5.  
  6.  
  7.  
  8.                ╔════════════════════════════════════════╗
  9.                ║                                        ║░
  10.                ║          AVONTURE CHRISTOPHE           ║░
  11.                ║              AVC SOFTWARE              ║░
  12.                ║     BOULEVARD EDMOND MACHTENS 157/53   ║░
  13.                ║           B-1080 BRUXELLES             ║░
  14.                ║              BELGIQUE                  ║░
  15.                ║                                        ║░
  16.                ╚════════════════════════════════════════╝░
  17.                ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  18.  
  19. }
  20.  
  21. FUNCTION No_Extension (st : String) : String;
  22.  
  23. VAR
  24.    wExtension : Word;
  25.  
  26. BEGIN
  27.  
  28.    wExtension := Pos('.', st);
  29.    Delete (St, wExtension, Length(st));
  30.    No_Extension := st;
  31.  
  32. END;
  33.  
  34. CONST
  35.  
  36.    IcoSize  = 766;
  37.    FileName = 'TEST.ICO';
  38.  
  39. TYPE
  40.    Buffer = ARRAY[1..IcoSize] OF Byte;
  41.  
  42. VAR
  43.    fIco    : File of Buffer;
  44.    fSource : Text;
  45.    Buf     : ^Buffer;
  46.    I       : Word;
  47.  
  48.  
  49. BEGIN
  50.  
  51.    IF PARAMCOUNT=0 THEN
  52.       BEGIN
  53.          Writeln ('');
  54.          Writeln ('AVC Software (c) AVONTURE Christophe');
  55.          Writeln ('');
  56.          Writeln ('');
  57.          Writeln ('Convert an ICO file to a pascal source file.');
  58.          Writeln ('Type ICO2PAS followed by the name of the ICO (extension must be there).');
  59.          Writeln ('');
  60.          Writeln ('  Example  ICO2PAS WINWORD.ICO will create a WINWORD.INC file');
  61.          Writeln ('');
  62.          Halt;
  63.       END;
  64.  
  65.    GetMem (Buf, IcoSize);
  66.  
  67.    Assign (fIco, ParamStr(1));
  68.    FileMode := 0;
  69.    Reset (fIco);
  70.  
  71.    Read (fIco, Buf^);
  72.  
  73.    Close (fIco);
  74.  
  75.  
  76.    Assign (fSource, No_Extension (FileName)+'.INC');
  77.    FIleMode := 1;
  78.    Rewrite (fSource);
  79.  
  80.    Writeln (fSource, 'Const '+No_Extension (FileName)+'_ICO : Array[1..766] of Byte =');
  81.  
  82.    FOR I := 1 TO IcoSize-1 DO
  83.       IF I = 1 THEN
  84.          Write (fSource, '           (', Buf^[I],',')
  85.       ELSE IF I Mod 20 = 19 THEN
  86.          BEGIN
  87.             Writeln (fSource, Buf^[I],',');
  88.             Write (fSource, '            ');
  89.          END
  90.       ELSE
  91.          Write (fSource, Buf^[I],',');
  92.  
  93.    Write (fSource, Buf^[IcoSize],');');
  94.  
  95.    Close (fSource);
  96.  
  97. END.